﻿using System;
using System.Collections.Generic;
using System.Text;
//该源码下载自【编程联盟】ASp.Net下载中心 http://aspx.bcbbs.net

namespace TuKu
{
    /// <summary>
    /// 下载任务信息
    /// </summary>
    public class DTaskData
    {
        /// <summary>
        /// 新建下载任务信息
        /// </summary>
        public DTaskData()
        {
            m_TaskConfigDatas = new List<DTaskConfigData>();
            m_Referer = "";
        }

        #region 属性

        private string m_Name;
        private string m_URL;
        private string m_Referer;
        private string m_TmpFileName;
        private string m_FileName;
        private string m_ConfigFileName;
        private bool m_SaveMode;
        private int m_Num;
        private long m_Size;
        private ulong m_CRC32;
        private long m_DownloadSize;
        private List<DTaskConfigData> m_TaskConfigDatas;

        /// <summary>
        /// 设置/获取 文件大小
        /// </summary>
        public long Size
        {
            get { return m_Size; }
            set { m_Size = value; }
        }
        /// <summary>
        /// 设置/获取 任务预定线程数
        /// </summary>
        public int Num
        {
            get { return m_Num; }
            set { m_Num = value; }
        }
        /// <summary>
        /// 设置/获取 CRC32校验值
        /// </summary>
        public ulong CRC32
        {
            get { return m_CRC32; }
            set { m_CRC32 = value; }
        }
        /// <summary>
        /// 设置/获取 已下载字节数（已写入硬盘的数据大小）
        /// </summary>
        public long DownloadSize
        {
            get { return m_DownloadSize; }
            set { m_DownloadSize = value; }
        }
        /// <summary>
        /// 设置/获取 任务名
        /// </summary>
        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }
        /// <summary>
        /// 设置/获取 下载地址
        /// </summary>
        public string URL
        {
            get { return m_URL; }
            set { m_URL = value; }
        }
        /// <summary>
        /// 设置/获取 引用页
        /// </summary>
        public string Referer
        {
            get { return m_Referer; }
            set { m_Referer = value; }
        }
        /// <summary>
        /// 设置/获取 下载临时文件名
        /// </summary>
        public string TmpFileName
        {
            get { return m_TmpFileName; }
            set
            {
                m_TmpFileName = value;
                if (m_ConfigFileName == null || m_ConfigFileName.Length == 0)
                {
                    m_ConfigFileName = value + ".dcf";
                }
            }
        }
        /// <summary>
        /// 设置/获取 下载文件名（保存到本地的完整路径）
        /// </summary>
        public string FileName
        {
            get { return m_FileName; }
            set
            {
                m_FileName = value;
                if (m_TmpFileName == null || m_TmpFileName.Length == 0)
                {
                    TmpFileName = value + ".dl";
                }
            }
        }
        /// <summary>
        /// 设置/获取 下载任务信息文件名
        /// </summary>
        public string ConfigFileName
        {
            get { return m_ConfigFileName; }
            set { m_ConfigFileName = value; }
        }
        /// <summary>
        /// 设置/获取 保存方式（覆盖[true]/重命名[false]）
        /// </summary>
        public bool SaveMode
        {
            get { return m_SaveMode; }
            set { m_SaveMode = value; }
        }

        /// <summary>
        /// 下载文件分块信息
        /// </summary>
        public List<DTaskConfigData> TaskConfigDatas
        {
            get { return m_TaskConfigDatas; }
            set { m_TaskConfigDatas = value; }
        }

        #endregion
    }
}
